<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    request.setAttribute("basePath",basePath);
%>
<%@ include file="/resources/js/easyui/taglibs.jsp"%>
<%@ include file="/resources/js/wechat/_wechatui.jsp"%>
<%@ include file="/resources/js/easyui/_viewJS.jsp"%>
<!DOCTYPE>
<html>
<head>
    <title>${place.address}</title>
</head>
<body>
<div class="loading"></div>
<!-- header -->
<header>
    <a href="javascript:history.go(-1);" class="top_fh">${place.address}</a>
</header>
<!-- header end -->

<div class="page">
    <div class="homecd_innerbox">
        <div class="tcbanner"><img src="${basePath}/resources/images/wechat/taocan_banner.jpg" alt=""></div>
        <div class="cdbox_list">
            <ul>
                <li><p><span>场地编号</span><i>${index}</i></p></li>
                <li><a href="JavaScript:;" class='sbzt_name'><span>场地名称</span><i style="margin-right:1rem;">${place.address}</i></a></li>
                <li><p><span>设备列表</span><i></i></p></li>
                <li>
                    <c:forEach var="device" items="${deviceList}">
                        <a href="${basePath}wechat/operate/device/${device.deviceId}/showView">${device.deviceName}</a>
                    </c:forEach>
                </li>
            </ul>
        </div>
    </div>
</div>

<!-- 设备名称弹窗 -->
<%--<div class="home_sbnamepop ty_pop">
    <div class="popbg"></div>
    <div class="sbname_inner home_cdinner">
        <em>场地名称</em>
        <p><input type="text" name="address" value="${place.address}" /></p>
        <div><a href="JavaScript:;">取消</a><a href="JavaScript:;">确定</a></div>
    </div>
</div>--%>

<!-- 场地名称弹窗 -->
<div class="home_sbnamepop ty_pop">
    <div class="popbg"></div>
    <div class="sbname_inner">
        <em>场地名称</em>
        <p><input type="text" class="addressName" value="${place.address}"/></p>
        <div><a href="JavaScript:;">取消</a><a href="JavaScript:;">确定</a></div>
    </div>
</div>
<!-- 设备名称弹窗 end -->



<!-- footer -->
<div class="zmxq_footer home_footer">
    <a href="${basePath}wechat/operate/device/listView">设备</a>
    <a href="${basePath}wechat/operate/place/listView" class="cur">场地</a>
</div>
<!-- footer end -->

<script type="application/javascript">
    //限制场地名称输入框长度、类型
    $(".addressName").long({"element":".addressName","action":"keyup","stringl":"1","stringls":"10","reg":/^.{0,20}$/, "stavalue":"场地1"});


    function View(){
        var that = this;

        that.events = [
            { sel : '#addSubBtn', act : 'click', func : 'addSub' }
        ];

        that.addSub = function(){
            $.ajax({
                url:'${basePath}wechat/operate/place/add',
                type : 'POST',
                data : $("#addform").serialize(),
                error: function (response) {
                    ViewHelper.func.ajaxWechatErrorMessage(response);
                },
                success: function (ret) {
                    if(ret.result) {
                        window.location = "${basePath}wechat/operate/place/listView";
                    }else{
                        alert(ret.info);
                    }
                }
            });
        };

        EventHandler.call(that, that.events);

        return that;
    }

    var view;

    $(function(){
        inherit(View, EventHandler);
        view = new View();
    });

    $(".sbname_inner div a").eq(1).on("click" , function(){
        var address = $(".sbname_inner p input").val();
        $.ajax({
            url:'${basePath}wechat/operate/place/${place.placeid}/edit',
            type : 'POST',
            data : {"address":address},
            error: function (response) {
                ViewHelper.func.ajaxWechatErrorMessage(response);
            },
            success: function (ret) {
                if(ret.result) {
                    window.location = "${basePath}wechat/operate/place/${place.placeid}/showView/${index}";
                }else{
                    alert(ret.info);
                }
            }
        });
    });

</script>

</body>
</html>